# -*- encoding: utf-8 -*-

from memory import ESP, EPC

class Call(object):

    """ Classe définissant une instruction Push Ra. """

    def __init__ (self, label, mem):
        self.__label = label
        self.__mem  = mem

    def do (self):
        self.__mem.setRamAt(
            addr = self.__mem.getRegister(ESP) - 1,
            newVal = self.__mem.getRegister(EPC) + 1
            )
        self.__mem.setRegister(ESP, self.__mem.getRegister(ESP) - 1)
        return self.__label

    def __str__ (self):
        return "call {0:s}".format(self.__label) 

    def __unicode__ (self):
        return self.__str__ () 
